<?php
require('../includes/init.php');

if($_GET['act']=='verify' && $_GET['mobile']<>'')
{
	$mobile = trim($_GET['mobile']);
	//验证手机号码是否正确

	$sql = "SELECT `user_id` FROM `user` WHERE `mobile`='".trim($_GET['mobile'])."';";
	$user = $db->getRow($sql);
	if(!$user){
		die('-1');
		exit;
	}

    if(time() - $_SESSION[SESSION_PREFIX]['code_send_time'] < 60){
		die('-2');
    }
	//发短信
	//随机码
	$code = '';
	for($i = 0; $i < 6; $i++)
    {
    	$code .= mt_rand(0, 9);
    }
		
	//发送手机验证码
    $send_sms_ok=send_sms_ali($mobile,array($code)); 
	if($send_sms_ok)
	{
        $_SESSION[SESSION_PREFIX]['code_send_time'] = time();
        $_SESSION[SESSION_PREFIX]['code_send_data'] = $code;
		die('1');
	}
	//发送异常
	else
	{
		die('0');
	}
}
